#pragma once

#include "base_type.h"
#include "pe.h"

#define MAX_CMD_LN_LEN 1024

typedef enum tag_cmd_id
{
	CMD_ERROR = -1,
	CMD_EMPTY,
	CMD_EXIT,
	CMD_HELP,
	CMD_OPEN,
	CMD_REFRESH,
	CMD_FILE,
	CMD_DUMP_DATA,
	CMD_RVA,
	CMD_OFFSET,

	CMD_HD_DOS,
	CMD_HD_NT,
	CMD_HD_PE_SIG,
	CMD_HD_FILE,
	CMD_HD_OPTIONAL,
	CMD_HD_SECTIONS,

	CMD_MD_CLIH,
	CMD_MD_HDRS,
	CMD_MD_ST_SIG,
	CMD_MD_ST_HDR,
	CMD_MD_STREAM_HDRS,
	CMD_MD_SNSIG,
	CMD_MD_RES,
	CMD_MD_VTFIXUP,

	CMD_MDT_HDR,
	CMD_MDT_LIST,
	CMD_MDT_LIST_WC,  // with columns
	CMD_MDT_CT,  // coded token
	CMD_MDT_CTRT,  // with referenced tables
	CMD_MDT_T,
	CMD_MDT_TI,

	CMD_MD_STR,   // #String[n]
	CMD_MD_US,  // #US[n]
	CMD_MD_GUID,   // #GUID[n]
	CMD_MD_BLOB,   // #Blob[n]

	CMD_IL_HDR,
	CMD_IL_FULL,
} cmd_id;

typedef struct tag_cmd
{
	cmd_id         id;
	size_t         range_start;
	size_t         range_len;
	union
	{
		str_wc     str_arg;
		size_t     szt_arg;
		table_id   tid_arg;
		str_wc     err_msg;
	};
} cmd;

void parse_cmd(str_wc cmd_line, cmd *ret_cmd);
void show_cmd_help(void);
